package com.gxgeek.spring.security.securitycore.validate;

import com.gxgeek.spring.security.securitycore.properties.SecurityProperties;
import com.gxgeek.spring.security.securitycore.validate.code.ValidateCodeGenerator;
import com.gxgeek.spring.security.securitycore.validate.code.image.ImageCodeGenerator;
import com.gxgeek.spring.security.securitycore.validate.code.sms.DefaultSmsCodeSender;
import com.gxgeek.spring.security.securitycore.validate.code.sms.SmsCodeSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author gaoxing
 * @create 2017-10-18 上午11:05
 */
@Configuration
public class ValidateCodeBeanConfig {
    @Autowired
    private SecurityProperties securityProperties;

    @Bean
    @ConditionalOnMissingBean(name = "imageValidateCodeGenerator")//这个注解先去找imageValidateCodeGenerator 找到了就不注册这个bean
    public ValidateCodeGenerator imageValidateCodeGenerator() {
        ImageCodeGenerator codeGenerator = new ImageCodeGenerator();
        return codeGenerator;
    }
    @Bean
    @ConditionalOnMissingBean(SmsCodeSender.class)
    public SmsCodeSender smsCodeSender() {
        return new DefaultSmsCodeSender();
    }


}
